////////////////////////////////////////////////////////////////////////////////
// Copyright 2010 Michael Schmalle - Teoti Graphix, LLC
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0 
// 
// Unless required by applicable law or agreed to in writing, software 
// distributed under the License is distributed on an "AS IS" BASIS, 
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and 
// limitations under the License
// 
// Author: Michael Schmalle, Principal Architect
// mschmalle at teotigraphix dot com
////////////////////////////////////////////////////////////////////////////////

package org.teotigraphix.swizplugin.services
{

import flash.events.IEventDispatcher;

import org.swizframework.events.BeanEvent;

/**
 * The <strong>BeanService</strong> is the default implementation 
 * of <code>IBeanService</code>.
 * 
 * @author Michael Schmalle
 * @copyright Teoti Graphix, LLC
 * @productversion 1.0
 */
public class BeanService implements IBeanService
{
	//--------------------------------------------------------------------------
	//
	//  Public :: Variables
	//
	//--------------------------------------------------------------------------
	
	[Dispatcher]
	public var dispatcher:IEventDispatcher;
	
	//--------------------------------------------------------------------------
	//
	//  Constructor
	//
	//--------------------------------------------------------------------------
	
	/**
	 * @private
	 * The serivce is instatiated in a BeanProvider.
	 */
	public function BeanService()
	{
	}
	
	//--------------------------------------------------------------------------
	//
	//  IBeanService API :: Methods
	//
	//--------------------------------------------------------------------------
	
	/**
	 * @copy org.teotigraphix.swizplugin.services.IBeanService#setUpBean()
	 */
	public function setUpBean(bean:Object, uid:String = null):void
	{
		var event:BeanEvent = new BeanEvent(
			BeanEvent.SET_UP_BEAN, bean, uid);
		dispatcher.dispatchEvent(event);
	}
	
	/**
	 * @copy org.teotigraphix.swizplugin.services.IBeanService#tearDownBean()
	 */
	public function tearDownBean(bean:Object, uid:String = null):void
	{
		var event:BeanEvent = new BeanEvent(
			BeanEvent.TEAR_DOWN_BEAN, bean, uid);
		dispatcher.dispatchEvent(event);
	}
}
}